#define PMU_HAS_SWI		0
#define PMU_HAS_DWI		1
#define PMU_HAS_REG_BANK	1
#define PMU_HAS_BIST_ADC	1
#define PMU_HAS_LCM_LDO		1
#define PMU_HAS_WLED		1

enum {
	kDIALOG_ADDR_R	= 0x79,
	kDIALOG_ADDR_W	= 0x78,
	kDIALOG_REG_BYTES	= 1,
};

enum {
	kDIALOG_EVENT_COUNT		= 9,
	kDIALOG_STATUS_COUNT		= 6,
	kDIALOG_HIBERNATE_COUNT		= 4,
	kDIALOG_CHIPID_COUNT		= 1,
	kDIALOG_FAULTLOG_COUNT		= 1,
	kDIALOG_GPIO_COUNT		= 18,
};

#include "dCommon.h"

enum {
	kDIALOG_BANK_COUNT		= 3,
    	kDIALOG_BANK0_SHARED_COUNT	= 0x57,
};

enum {
	kDIALOG_CHIP_ID			= 0x00,

	kDIALOG_EVENT_A			= 0x01,
	kDIALOG_EVENT_B			= 0x02,
	kDIALOG_EVENT_C			= 0x03,
	kDIALOG_EVENT_D			= 0x04,
	kDIALOG_EVENT_E			= 0x05,
	kDIALOG_EVENT_F			= 0x06,
	kDIALOG_EVENT_G			= 0x07,
	kDIALOG_EVENT_H			= 0x08,
	kDIALOG_EVENT_K			= 0x09,

	kDIALOG_STATUS_A		= 0x0a,
	kDIALOG_STATUS_B		= 0x0b,
	kDIALOG_STATUS_C		= 0x0c,
	kDIALOG_STATUS_D		= 0x0d,
	kDIALOG_STATUS_E		= 0x0e,
	kDIALOG_STATUS_F		= 0x0f,
	kDIALOG_STATUS_G		= 0x10,
	kDIALOG_STATUS_H		= 0x11,

	kDIALOG_IRQ_MASK_A		= 0x12,
	kDIALOG_IRQ_MASK_B		= 0x13,
	kDIALOG_IRQ_MASK_C		= 0x14,
	kDIALOG_IRQ_MASK_D		= 0x15,
	kDIALOG_IRQ_MASK_E		= 0x16,
	kDIALOG_IRQ_MASK_F		= 0x17,
	kDIALOG_IRQ_MASK_G		= 0x18,
	kDIALOG_IRQ_MASK_H		= 0x19,
	kDIALOG_IRQ_MASK_K		= 0x1a,

	kDIALOG_SYS_CONTROL		= 0x1b,
	kDIALOG_SYS_CONTROL2		= 0x1c,

	kDIALOG_FAULT_LOG		= 0x1d,
	kDIALOG_BANKSEL			= 0x1e,

	kD1946_ACTIVE1			= 0x20,
	kD1946_ACTIVE2			= 0x21,
	kD1946_ACTIVE3			= 0x22,
	kDIALOG_LCM_ACTIVE		= kD1946_ACTIVE3,
	kD1946_ACTIVE4			= 0x23,
	kD1946_STANDBY1			= 0x24,
	kDIALOG_STANDBY			= kD1946_STANDBY1,
	kD1946_HIBERNATE1		= 0x25,
	kD1946_HIBERNATE2		= 0x26,
	kD1946_HIBERNATE3		= 0x27,
	kD1946_HIBERNATE4		= 0x28,

	kD1946_BUCK0			= 0x29,
	kDIALOG_BUCK0			= kD1946_BUCK0,
	kD1946_BUCK1			= 0x2a,
	kD1946_BUCK2			= 0x2b,
	kDIALOG_BUCK2			= kD1946_BUCK2,
	kD1946_BUCK3			= 0x2c,
	kD1946_BUCK4			= 0x2d,
	kD1946_BUCK5			= 0x2e,

	kD1946_LDO1			= 0x2f,
	kD1946_LDO2			= 0x30,
	kD1946_LDO3			= 0x31,
	kD1946_LDO4			= 0x32,
	kD1946_LDO5			= 0x33,
	kD1946_LDO6			= 0x34,
	kD1946_LDO7			= 0x35,
	kD1946_LDO8			= 0x36,
	kD1946_LDO9			= 0x37,
	kD1946_LDO10			= 0x38,
	kD1946_LDO11			= 0x39,
	kD1946_LDO12			= 0x3a,

	kDIALOG_BUCK_DWI		= 0x3b,

	kDIALOG_CHARGE_BUCK_CONTROL	= 0x3d,
	kDIALOG_CHARGE_BUCK_CONTROL_B	= 0x3e,

	kDIALOG_CHARGE_CONTROL_A	= 0x3f,
	kDIALOG_CHARGE_CONTROL_B	= 0x40,
	kDIALOG_CHARGE_CONTROL_C	= 0x41,
	kDIALOG_CHARGE_TIME		= 0x42,
	kDIALOG_CHARGE_CONTROL_ICHG_BAT = kDIALOG_CHARGE_CONTROL_A,
	kDIALOG_CHARGE_CONTROL_HIB	= kDIALOG_CHARGE_CONTROL_A,
	kDIALOG_CHARGE_CONTROL_TIME	= kDIALOG_CHARGE_CONTROL_C,
	kDIALOG_CHARGE_CONTROL_EN	= kDIALOG_CHARGE_CONTROL_B,
	kDIALOG_OTP_ISET_BAT		= kDIALOG_CHARGE_CONTROL_A,  // not a real OTP register

	kDIALOG_ADC_CONTROL		= 0x43,
	kDIALOG_ADC_LSB			= 0x44,
	kDIALOG_ADC_MSB			= 0x45,

	kDIALOG_ICHG_AVG		= 0x47,

	kDIALOG_TBAT_0			= 0x4a,
	kDIALOG_ICHG_TBAT_0		= 0x4b,
	kDIALOG_TBAT_1			= 0x4c,
	kDIALOG_ICHG_TBAT_1		= 0x4d,
	kDIALOG_TBAT_2			= 0x4e,
	kDIALOG_ICHG_TBAT_2		= 0x4f,
	kDIALOG_TBAT_3			= 0x50,
	kDIALOG_ICHG_TBAT_3		= 0x51,
	kDIALOG_TBAT_4			= 0x52,
	kDIALOG_ICHG_TBAT_4		= 0x53,
	kDIALOG_TBAT_MAX		= 0x54,
	kDIALOG_ICHG_TBAT_NUM		= 5,

	kDIALOG_T_OFFSET_MSB		= 0x55,
	kDIALOG_T_OFFSET_LSB		= 0x56,

	kDIALOG_RTC_ALARM_A		= 0x57,
	kDIALOG_RTC_ALARM_B		= 0x58,
	kDIALOG_RTC_ALARM_C		= 0x59,
	kDIALOG_RTC_ALARM_D		= 0x5a,
	kDIALOG_RTC_CONTROL		= 0x5b,
	kDIALOG_RTC_TIMEZONE		= 0x5c,
	kDIALOG_UPCOUNT_A		= 0x5d,
	kDIALOG_UPCOUNT_B		= 0x5e,
	kDIALOG_UPCOUNT_C		= 0x5f,
	kDIALOG_UPCOUNT_D		= 0x60,

	kD1946_SYS_GPIO_1		= 0x61,
	kDIALOG_SYS_GPIO_REG_START	= kD1946_SYS_GPIO_1,
	kD1946_SYS_GPIO_2		= 0x62,
	kD1946_SYS_GPIO_3		= 0x63,
	kD1946_SYS_GPIO_4		= 0x64,
	kD1946_SYS_GPIO_5		= 0x65,
	kD1946_SYS_GPIO_6		= 0x66,
	kD1946_SYS_GPIO_7		= 0x67,
	kD1946_SYS_GPIO_8		= 0x68,
	kD1946_SYS_GPIO_9		= 0x69,
	kD1946_SYS_GPIO_10		= 0x6a,
	kD1946_SYS_GPIO_11		= 0x6b,
	kD1946_SYS_GPIO_12		= 0x6c,
	kD1946_SYS_GPIO_13		= 0x6d,
	kD1946_SYS_GPIO_14		= 0x6e,
	kD1946_SYS_GPIO_15		= 0x6f,
	kD1946_SYS_GPIO_16		= 0x70,
	kD1946_SYS_GPIO_17		= 0x71,
	kD1946_SYS_GPIO_18		= 0x72,

	kD1946_SYS_GPIO_DEB1		= 0x73,
	kD1946_SYS_GPIO_DEB2		= 0x74,
	kD1946_SYS_GPIO_DEB3		= 0x75,
	kD1946_SYS_GPIO_DEB4		= 0x76,
	kD1946_SYS_GPIO_DEB5		= 0x77,
	kD1946_SYS_GPIO_DEB6		= 0x78,
	kD1946_SYS_GPIO_DEB7		= 0x79,
	kD1946_SYS_GPIO_DEB8		= 0x7a,
	kD1946_SYS_GPIO_DEB9		= 0x7b,
	
	kDIALOG_LDO_CONTROL		= 0x7c,

	kD1946_BUTTON1			= 0x7d,
	kD1946_BUTTON2			= 0x7e,
	kD1946_BUTTON3			= 0x7f,
	kDIALOG_SYS_CONFIG		= 0x80,

	kD1946_LCM_CONTROL1		= 0x81,
	kD1946_LCM_CONTROL2		= 0x82,
	kD1946_LCM_CONTROL3		= 0x83,
	kD1946_LCM_BST_CONTROL		= 0x84,
	kDIALOG_LCM_BOOST		= kD1946_LCM_BST_CONTROL,

	kD1946_BUCK3_HIB		= 0x9a,
	kD1946_BUCK4_HIB		= 0x9b,
	kD1946_GPIO_SOFTHIB1		= 0x9c,
	kD1946_GPIO_SOFTHIB2		= 0x9d,
	kD1946_GPIO_SOFTHIB3		= 0x9e,
	kDIALOG_BUTTON_DBL		= 0x9f,

	kDIALOG_MEMBYTE0		= 0xa0,
	kDIALOG_MEMBYTE_LAST		= 0xc7,

	kDIALOG_WLED_ISET		= 0xd0,
	kDIALOG_WLED_ISET2		= 0xd1,
	kDIALOG_WLED_CONTROL		= 0xd2,
	kDIALOG_WLED_CONTROL2		= 0xd3,
	kDIALOG_WLED_DWI_CONTROL	= kDIALOG_WLED_CONTROL2,
	kDIALOG_WLED_OPTIONS		= kDIALOG_WLED_CONTROL2,

	// Bank 1 Test Registers
	kD1946_WLED_CONTROL5            = 0xa5,
	kD1946_BUCK_CONTROL1            = 0xab,
	kD1946_BUCK_CONTROL3            = 0xad,

	// Bank 2 Test Registers
	kD1946_TEST_MODE                = 0xd0,

	kDIALOG_APP_TMUX		= 0x15c,
	kDIALOG_BIST_ADC_CTRL		= 0x15d,
	kDIALOG_BIST_ADC_LSB		= 0x15e,
	kDIALOG_BIST_ADC_MSB		= 0x15f,
};

enum {
	kD1946_CHIP_ID_MRC_MASK		= (0xf << 0),
	kD1946_CHIP_ID_MRC_A0		= (0 << 0),
	kD1946_CHIP_ID_MRC_A1		= (1 << 0),
};

enum {
	kD1946_EVENT_A_BUTTON1		= (1 << 0),
	kD1946_EVENT_A_BUTTON2		= (1 << 1),
	kD1946_EVENT_A_BUTTON3		= (1 << 2),
	kD1946_EVENT_A_VCENTER_DET	= (1 << 3),
	kD1946_EVENT_A_FW_DET		= (1 << 4),
	kD1946_EVENT_A_ACC_DET		= (1 << 5),
	kD1946_EVENT_A_VBUS_EXT_DET	= (1 << 6),
	kD1946_EVENT_A_VDD_LOW		= (1 << 7),
};

// EVENT_B events are assumed volatile (lost over sleep/wake)
enum {
	kD1946_EVENT_B_DWI_TO		= (1 << 0),
	kD1946_EVENT_B_CHG_PRE		= (1 << 1),
	kD1946_EVENT_B_CHG_FAST		= (1 << 2),
	kD1946_EVENT_B_CHG_END		= (1 << 3),
	kD1946_EVENT_B_TBAT		= (1 << 4),
	kD1946_EVENT_B_EOMC		= (1 << 5),
	kD1946_EVENT_B_FW_OV		= (1 << 6),
	kDIALOG_EVENT_B_HIB		= (1 << 7),
};

enum {
	kD1946_EVENT_C_GPIO1		= (1 << 0),
	kD1946_EVENT_C_GPIO2		= (1 << 1),
	kD1946_EVENT_C_GPIO3		= (1 << 2),
	kD1946_EVENT_C_GPIO4		= (1 << 3),
	kD1946_EVENT_C_GPIO5		= (1 << 4),
	kD1946_EVENT_C_GPIO6		= (1 << 5),
	kD1946_EVENT_C_GPIO7		= (1 << 6),
	kD1946_EVENT_C_GPIO8		= (1 << 7),
};

enum {
	kD1946_EVENT_D_GPIO9		= (1 << 0),
	kD1946_EVENT_D_GPIO10		= (1 << 1),
	kD1946_EVENT_D_GPIO11		= (1 << 2),
	kD1946_EVENT_D_GPIO12		= (1 << 3),
	kD1946_EVENT_D_GPIO13		= (1 << 4),
	kD1946_EVENT_D_GPIO14		= (1 << 5),
	kD1946_EVENT_D_GPIO15		= (1 << 6),
	kD1946_EVENT_D_GPIO16		= (1 << 7),
};

enum {
	kD1946_EVENT_E_GPIO17		= (1 << 0),
	kD1946_EVENT_E_GPIO18		= (1 << 1),
	kD1946_EVENT_E_ACC_B_DET	= (1 << 2),
	kD1946_EVENT_E_BTN1_DBL		= (1 << 3),
	kD1946_EVENT_E_BTN2_DBL		= (1 << 4),
	kD1946_EVENT_E_BTN3_DBL		= (1 << 5),
	kD1946_EVENT_E_CHG_BUCK_FLG	= (1 << 6),
	kD1946_EVENT_E_VBUS_OV		= (1 << 7),
};

enum {
	kD1946_EVENT_G_ALARM		= (1 << 0),
	kD1946_EVENT_G_FW_REM		= (1 << 4),
	kD1946_EVENT_G_VBUS_REM		= (1 << 6),
};

enum {
	kD1946_EVENT_K_VBUS_B_DET	= (1 << 3),
	kD1946_EVENT_K_CHG_BUCK_B_FLG	= (1 << 5),
	kD1946_EVENT_K_VBUS_B_EXT	= (1 << 6),
	kD1946_EVENT_K_VBUS_B_REM	= (1 << 7),
};

enum {
	kD1946_STATUS_A_BUTTON1		= (1 << 0),
	kD1946_STATUS_A_BUTTON2		= (1 << 1),
	kD1946_STATUS_A_BUTTON3		= (1 << 2),
	kD1946_STATUS_A_VCENTER_DET	= (1 << 3),
	kD1946_STATUS_A_FW_DET		= (1 << 4),
	kD1946_STATUS_A_ACC_DET		= (1 << 5),
	kD1946_STATUS_A_VBUS_EXT_DET	= (1 << 6),
	kD1946_STATUS_A_VDD_LOW		= (1 << 7),
};

enum {
	kD1946_STATUS_B_CHG_ATT		= (1 << 0),
	kD1946_STATUS_B_CHG_PRE		= (1 << 1),
	kD1946_STATUS_B_CHG_FAST	= (1 << 2),
	kD1946_STATUS_B_CHG_END		= (1 << 3),
	kD1946_STATUS_B_TBAT		= (1 << 4),
	kD1946_STATUS_B_CHG_TO		= (1 << 5),
	kD1946_STATUS_B_FW_OV		= (1 << 6),
};

enum {
	kD1946_STATUS_C_GPIO1		= (1 << 0),
	kD1946_STATUS_C_GPIO2		= (1 << 1),
	kD1946_STATUS_C_GPIO3		= (1 << 2),
	kD1946_STATUS_C_GPIO4		= (1 << 3),
	kD1946_STATUS_C_GPIO5		= (1 << 4),
	kD1946_STATUS_C_GPIO6		= (1 << 5),
	kD1946_STATUS_C_GPIO7		= (1 << 6),
	kD1946_STATUS_C_GPIO8		= (1 << 7),
};

enum {
	kD1946_STATUS_D_GPIO9		= (1 << 0),
	kD1946_STATUS_D_GPIO10		= (1 << 1),
	kD1946_STATUS_D_GPIO11		= (1 << 2),
	kD1946_STATUS_D_GPIO12		= (1 << 3),
	kD1946_STATUS_D_GPIO13		= (1 << 4),
	kD1946_STATUS_D_GPIO14		= (1 << 5),
	kD1946_STATUS_D_GPIO15		= (1 << 6),
	kD1946_STATUS_D_GPIO16		= (1 << 7),
};

enum {
	kD1946_STATUS_E_GPIO17		= (1 << 0),
	kD1946_STATUS_E_GPIO18		= (1 << 1),
	kD1946_STATUS_E_ACC_B_DET	= (1 << 2),
	kD1946_STATUS_E_PROT_FET_ON	= (1 << 3),
	kD1946_STATUS_E_PROT_FET_B_ON	= (1 << 5),
	kD1946_STATUS_E_CHG_BUCK_FLG	= (1 << 6),
	kD1946_STATUS_E_VBUS_OV		= (1 << 7),
};

enum {
	kD1946_STATUS_H_CHG_B_ATT	= (1 << 0),
	kD1946_STATUS_H_VBUS_B_OV	= (1 << 1),
	kD1946_STATUS_H_VCENTER_B_DET	= (1 << 3),
	kD1946_STATUS_H_CHG_BUCK_B_FLG	= (1 << 5),
	kD1946_STATUS_H_VBUS_B_EXT_DET	= (1 << 6),
};

enum {
	kDIALOG_EVENT_HOLD_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1946_EVENT_A_BUTTON2),
	kDIALOG_EVENT_MENU_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1946_EVENT_A_BUTTON1),
	kDIALOG_EVENT_RINGER_BUTTON_MASK= EVENT_FLAG_MAKE(0, kD1946_EVENT_A_BUTTON3),
	kDIALOG_EVENT_BUTTONS		= (kD1946_EVENT_A_BUTTON2 | 
					   kD1946_EVENT_A_BUTTON1 | 
					   kD1946_EVENT_A_BUTTON3),
	kDIALOG_EVENT_BUTTONS_MASK	= EVENT_FLAG_MAKE(0, kDIALOG_EVENT_BUTTONS),
	kDIALOG_EVENT_PWR_BUTTON_MASK	= kDIALOG_EVENT_HOLD_BUTTON_MASK,
	
	kDIALOG_EVENT_ALARM_MASK	= EVENT_FLAG_MAKE(6, kD1946_EVENT_G_ALARM),
	kDIALOG_EVENT_ACC_DET_MASK	= EVENT_FLAG_MAKE(0, kD1946_EVENT_A_ACC_DET),
	kDIALOG_EVENT_VBUS_DET_MASK	= EVENT_FLAG_MAKE(0, kD1946_EVENT_A_VBUS_EXT_DET),
	kDIALOG_EVENT_VHP_DET_MASK	= EVENT_FLAG_MAKE(0, kD1946_STATUS_A_FW_DET),
	kDIALOG_EVENT_VBUS_REM_MASK	= EVENT_FLAG_MAKE(6, kD1946_EVENT_G_VBUS_REM),
	kDIALOG_EVENT_EOMC_MASK		= EVENT_FLAG_MAKE(1, kD1946_EVENT_B_EOMC),
	kDIALOG_EVENT_HIB_MASK		= EVENT_FLAG_MAKE(1, kDIALOG_EVENT_B_HIB),
	
	kDIALOG_EVENT_CHG_END_MASK	= EVENT_FLAG_MAKE(1, kD1946_EVENT_B_CHG_END),
	kDIALOG_EVENT_TBAT_MASK		= EVENT_FLAG_MAKE(1, kD1946_EVENT_B_TBAT),
	
	kDIALOG_EVENT_GPIO1_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO1),
	kDIALOG_EVENT_GPIO2_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO2),
	kDIALOG_EVENT_GPIO3_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO3),
	kDIALOG_EVENT_GPIO4_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO4),
	kDIALOG_EVENT_GPIO5_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO5),
	kDIALOG_EVENT_GPIO6_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO6),
	kDIALOG_EVENT_GPIO7_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO7),
	kDIALOG_EVENT_GPIO8_MASK	= EVENT_FLAG_MAKE(2, kD1946_EVENT_C_GPIO8),
	kDIALOG_EVENT_GPIO9_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO9),
	kDIALOG_EVENT_GPIO10_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO10),
	kDIALOG_EVENT_GPIO11_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO11),
	kDIALOG_EVENT_GPIO12_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO12),
	kDIALOG_EVENT_GPIO13_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO13),
	kDIALOG_EVENT_GPIO14_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO14),
	kDIALOG_EVENT_GPIO15_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO15),
	kDIALOG_EVENT_GPIO16_MASK	= EVENT_FLAG_MAKE(3, kD1946_EVENT_D_GPIO16),
	kDIALOG_EVENT_GPIO17_MASK	= EVENT_FLAG_MAKE(4, kD1946_EVENT_E_GPIO17),
	kDIALOG_EVENT_GPIO18_MASK	= EVENT_FLAG_MAKE(4, kD1946_EVENT_E_GPIO18),

	kDIALOG_EVENT_HOLD_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1946_EVENT_E_BTN2_DBL),
	kDIALOG_EVENT_MENU_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1946_EVENT_E_BTN1_DBL),
	kDIALOG_EVENT_RINGER_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1946_EVENT_E_BTN3_DBL),

	kDIALOG_EVENT_ON_MASK		= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_LDO2_EN_MASK	= kDIALOG_NOTEXIST_MASK,
};

enum {
	kDIALOG_STATUS_USB_MASK		 = STATUS_FLAG_MAKE(0, kD1946_STATUS_A_VCENTER_DET),
	kDIALOG_STATUS_VBUS_MASK	 = STATUS_FLAG_MAKE(0, kD1946_STATUS_A_VBUS_EXT_DET),
	kDIALOG_STATUS_FW_MASK		 = STATUS_FLAG_MAKE(0, kD1946_STATUS_A_FW_DET),
	kDIALOG_STATUS_ACC_DET_MASK	 = STATUS_FLAG_MAKE(0, kD1946_STATUS_A_ACC_DET),
	kDIALOG_STATUS_CHARGING_MASK	 = STATUS_FLAG_MAKE(1, kD1946_STATUS_B_CHG_PRE | kD1946_STATUS_B_CHG_FAST),
	kDIALOG_STATUS_CHG_TO_MASK	 = STATUS_FLAG_MAKE(1, kD1946_STATUS_B_CHG_TO),
	kDIALOG_STATUS_CHG_END_MASK	 = STATUS_FLAG_MAKE(1, kD1946_STATUS_B_CHG_END),
	kDIALOG_STATUS_TBAT_MASK	 = STATUS_FLAG_MAKE(1, kD1946_STATUS_B_TBAT),
	kDIALOG_STATUS_CHG_ATT_MASK      = STATUS_FLAG_MAKE(1, kD1946_STATUS_B_CHG_ATT),
#define	kDIALOG_STATUS_GPIO_MASK(gpio)	   STATUS_FLAG_MAKE(2 + ((gpio)/8), (1 << ((gpio) % 8)))
};

static const statusRegisters kDialogStatusFWMask = {kD1946_STATUS_A_FW_DET, 0, 0, 0, 0, 0};
static const statusRegisters kDialogStatusChargingMask = {0, kD1946_STATUS_B_CHG_PRE | kD1946_STATUS_B_CHG_FAST, 0, 0, 0, 0};

enum {
	kD1946_EVENT_A_WAKEMASK = (kD1946_EVENT_A_BUTTON1 |
				   kD1946_EVENT_A_BUTTON2 |
				   kD1946_EVENT_A_BUTTON3 |
				   kD1946_EVENT_A_VBUS_EXT_DET |
				   kD1946_STATUS_A_FW_DET |
				   kD1946_EVENT_A_ACC_DET),
	kD1946_EVENT_B_WAKEMASK = 0,
	kD1946_EVENT_C_WAKEMASK = 0,
	kD1946_EVENT_D_WAKEMASK = 0,
	kD1946_EVENT_E_WAKEMASK = 0,
	kD1946_EVENT_F_WAKEMASK = 0,
	kD1946_EVENT_G_WAKEMASK = (kD1946_EVENT_G_ALARM |
				   kD1946_EVENT_G_FW_REM |
				   kD1946_EVENT_G_VBUS_REM),
	kD1946_EVENT_H_WAKEMASK = 0,
	kD1946_EVENT_K_WAKEMASK = 0,
};

// All events that are masked during shutdown - inverse of the wake mask,
// events that wake up the system
static const eventRegisters kDialogEventIntMasks = {
	~kD1946_EVENT_A_WAKEMASK,
	~kD1946_EVENT_B_WAKEMASK,
	~kD1946_EVENT_C_WAKEMASK,
	~kD1946_EVENT_D_WAKEMASK,
	~kD1946_EVENT_E_WAKEMASK,
	~kD1946_EVENT_F_WAKEMASK,
	~kD1946_EVENT_G_WAKEMASK,
	~kD1946_EVENT_H_WAKEMASK,
	~kD1946_EVENT_K_WAKEMASK,
};


// All wake events without the buttons
static const eventRegisters kDialogEventNotButtonMasks = {
	kD1946_EVENT_A_WAKEMASK & ~kDIALOG_EVENT_BUTTONS,
	kD1946_EVENT_B_WAKEMASK,
	kD1946_EVENT_C_WAKEMASK,
	kD1946_EVENT_D_WAKEMASK,
	kD1946_EVENT_E_WAKEMASK,
	kD1946_EVENT_F_WAKEMASK,
	kD1946_EVENT_G_WAKEMASK,
	kD1946_EVENT_H_WAKEMASK,
	kD1946_EVENT_K_WAKEMASK,
};

// All events that defer shutdown
static const eventRegisters kDialogEventRestartMask = { 
	EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_HOLD_BUTTON_MASK, 0) | EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ACC_DET_MASK, 0),
	0,
	0,
	0,
	0,
	0,
	EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ALARM_MASK, 6),
	0,
	0,
};

// All events indicating external power supply
static const eventRegisters kDialogEventPwrsupplyMask = {
	kD1946_EVENT_A_VBUS_EXT_DET | kD1946_EVENT_A_FW_DET | kD1946_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	0,
	kD1946_EVENT_G_FW_REM | kD1946_EVENT_G_VBUS_REM,
	0,
	0,
};

static const eventRegisters kDialogEventUSBMask = {
	// only include VCENTER_DET; VBUS can come and go while charger still usable
	kD1946_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
	0,
};

static const eventRegisters kDialogEventFWMask = {
	kD1946_EVENT_A_FW_DET,
	0,
	0,
	0,
	0,
	0,
	kD1946_EVENT_G_FW_REM,
	0,
	0,
};

// XXXKW
enum {
	kDialogEventPwrsupplyCount = 5,
	kDialogEventUSBCount = 1,
	kDialogEventFWCount = 2,
};

enum {
	kDIALOG_LCM_ACTIVE_BOOST_EN		= (1 << 1),
	kDIALOG_LCM_ACTIVE_MASK			= (1 << 2) | (1 << 3) | (1 << 4),
};

enum {
	kDIALOG_SYS_CONTROL_STANDBY		= (1 << 0),
	kDIALOG_SYS_CONTROL_HIBERNATE		= (1 << 1),
	kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND	= (1 << 2),
	kDIALOG_SYS_CONTROL_SOFT_HIB		= (1 << 3),
	kDIALOG_SYS_CONTROL_HIB_CLK		= (1 << 4),
	kDIALOG_SYS_CONTROL_PRO_FET_DIS		= (1 << 5),
	kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND	= (1 << 6),
	kDIALOG_SYS_CONTROL_CHRG_CONTROLS	= kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND
						| kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND,
	kDIALOG_SYS_CONTROL_HIBERNATE_ALWAYS    = kDIALOG_SYS_CONTROL_HIBERNATE,
};

enum {
	kDIALOG_SYS_CONTROL2_DWI_EN		= (1 << 0),
	kDIALOG_SYS_CONTROL2_DWI_TEST_EN	= (1 << 1),
	kDIALOG_SYS_CONTROL2_HIB_32K		= (1 << 4),
	kDIALOG_SYS_CONTROL2_BAT_PWR_SUSPEND	= (1 << 7),
};

enum {
	kDIALOG_FAULT_LOG_WDOG		= FAULTLOG_FLAG_MAKE(0, (1 << 6)),
	kDIALOG_FAULT_LOG_RESET_IN_1	= FAULTLOG_FLAG_MAKE(0, (1 << 5)),
	kDIALOG_FAULT_LOG_RST		= FAULTLOG_FLAG_MAKE(0, (1 << 4)),
	kDIALOG_FAULT_LOG_POR		= FAULTLOG_FLAG_MAKE(0, (1 << 3)),
	kDIALOG_FAULT_LOG_BOOST		= FAULTLOG_FLAG_MAKE(0, (1 << 2)),
	kDIALOG_FAULT_LOG_OVER_TEMP	= FAULTLOG_FLAG_MAKE(0, (1 << 1)),
	kDIALOG_FAULT_LOG_VDD_UNDER	= FAULTLOG_FLAG_MAKE(0, (1 << 0)),
	kDIALOG_FAULT_LOG_RESET_IN_2	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_RESET_IN_3	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_NTC_SHDN	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_BTN_SHUTDOWN	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_TWO_FINGER_RESET	= kDIALOG_NOTEXIST_MASK,
};

enum {
	kDIALOG_BUCK_DWI_BUCK0			= (1 << 0),
	kDIALOG_BUCK_DWI_BUCK1			= (1 << 1),
	kDIALOG_BUCK_DWI_BUCK2			= (1 << 2),
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MIN  = 0x00,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_100  = 0x02,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_200  = 0x0a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_300  = 0x12,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_400  = 0x1a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_500  = 0x22,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_600  = 0x2a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_700  = 0x32,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_900  = 0x42,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_975  = 0x48,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1000 = 0x4a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1450 = 0x6e,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1500 = 0x72,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2000 = 0x9a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2100 = 0xa2,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MAX  = 0xff,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MASK = 0xff,
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_MIN		   = 75,
	kDIALOG_CHARGE_BUCK_CONTROL_STEP_PER_100MA = 8,
	kDIALOG_CHARGE_BUCK_CONTROL_MAX		   = 3262,
};

enum {
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_MASK	 = 0x3f,
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT  = 0,
	kDIALOG_OTP_ISET_BAT_SHIFT		= kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT,
	kDIALOG_CHARGE_CONTROL_A_CHG_SUSP	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_A_CHG_HIB	= (1 << 7),
	kDIALOG_CHARGE_CONTROL_CHG_HIB		= kDIALOG_CHARGE_CONTROL_A_CHG_HIB,
};

enum {
	kDIALOG_CHARGE_CONTROL_STEP		= 40,
	kDIALOG_CHARGE_CONTROL_MAX		= 2520,
};

enum {
	kDIALOG_CHARGE_CONTROL_B_ALT_USB_DIS	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_B_CHG_BUCK_EN	= (1 << 7),

	kDIALOG_CHARGE_BUCK_CONTROL_ISET_VBUS_CHG_BUCK_EN	= kDIALOG_CHARGE_CONTROL_B_CHG_BUCK_EN,
	kDIALOG_CHARGE_CONTROL_ALT_USB_DIS                      = kDIALOG_CHARGE_CONTROL_B_ALT_USB_DIS,
	kDIALOG_CHARGE_CONTROL_CHG_BUCK_EN                      = kDIALOG_CHARGE_CONTROL_B_CHG_BUCK_EN,
};

enum {
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_MASK	    = 0xF0,
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_DISABLED   = 0x00,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_MASK	    = 0x07,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_DISABLED   = 0x00,
};

enum {
	kDIALOG_ADC_LSB_ADC_OVL			= (1 << 7),
};

enum {
	kDIALOG_ADC_CONTROL_MUX_SEL_MASK	= (0x1f << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VDD_OUT	= (0x0 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ICH		= (0x1 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TBAT	= (0x2 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ACC_ID	= (0x3 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VBAT	= (0x4 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_OUT	= (0x5 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BRICK_ID	= (0x6 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IN7	= (0x7 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TJUNC	= (0x8 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_IN	= (0x9 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_NTC0	= (0xa << 0),
	kDIALOG_ADC_CONTROL_MUX_NUM_NTC		= 5,
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS_A	= (15 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS	= kDIALOG_ADC_CONTROL_MUX_SEL_VBUS_A,
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_IN_OFF	= (16 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_OUT_OFF= (17 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK5_TEMP	= (18 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_LDO9_TEMP	= (19 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_B_TEMP= (20 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CHG_TEMP	= (21 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK0_TEMP	= (22 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK2_TEMP	= (23 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK3_TEMP	= (24 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK4_TEMP	= (25 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP= (26 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS_B	= (27 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_START	= kDIALOG_ADC_CONTROL_MUX_SEL_BUCK5_TEMP,
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_END	= kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP,
	kDIALOG_ADC_CONTROL_MAN_CONV		= (1 << 5),
	kDIALOG_ADC_CONTROL_ADC_REF_EN		= (1 << 6),
	kDIALOG_ADC_CONTROL_AUTO_VDD_OUT_EN	= (1 << 7),
};

enum {
	kDIALOG_ADC_CONTROL_DEFAULTS	= 0,
};

enum {
	kDIALOG_ADC_RESOLUTION_BITS	= 12,
	kDIALOG_ADC_FULL_SCALE_MV	= 2500,
	kDIALOG_ADC_BRICK_ID_OFFSET_MV	= 40,
};

enum {
    	kDIALOG_BIST_ADC_CTRL_MUX_SEL_MASK	= (0x3f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO1	= (0x00 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO1	= (0x01 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO2	= (0x02 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO2	= (0x03 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO3	= (0x04 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO3	= (0x05 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO4	= (0x06 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO4	= (0x07 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO5	= (0x08 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO5	= (0x09 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO6	= (0x0a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO6	= (0x0b << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO7	= (0x0c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO7	= (0x0d << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO8	= (0x0e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO8	= (0x0f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO9	= (0x10 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO9	= (0x11 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO10	= (0x12 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO10	= (0x13 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO11	= (0x14 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO11	= (0x15 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO12	= (0x16 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO12	= (0x17 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM1	= (0x18 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM1	= (0x19 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM2	= (0x1a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM2	= (0x1b << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM3	= (0x1c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM3	= (0x1d << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VRTC	= (0x1e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IRTC	= (0x1f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUF_ON	= (0x20 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IBUF_ON	= (0x21 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0	= (0x22 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK1	= (0x24 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK2	= (0x26 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK3	= (0x28 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK4	= (0x2a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_LED	= (0x2c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBOOST_LCM	= (0x2e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_A	= (0x30 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_B	= (0x32 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK5	= (0x34 << 0),
	kDIALOG_BIST_ADC_CTRL_AUTO_RUN		= (1 << 6),
	kDIALOG_BIST_ADC_CTRL_MAN_CONV		= (1 << 7),
};

enum {
	kDIALOG_APP_TMUX_SEL_MASK		= (7 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_0		= (0 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_1		= (1 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_2		= (2 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_3		= (3 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_4		= (4 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_5		= (5 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_6		= (6 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_7		= (7 << 0),
	KDIALOG_APP_TMUX_EN			= (1 << 7),
};

enum {
	kDIALOG_RTC_CONTROL_MONITOR		= (1 << 0),
	kDIALOG_RTC_CONTROL_ALARM_EN		= (1 << 6),
};

enum {
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_LOW		= (0 << 1),
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_HIGH		= (1 << 1),

	kDIALOG_SYS_GPIO_INPUT_WAKE			= (1 << 1),

	kDIALOG_SYS_GPIO_DIRECTION_MASK			= (7 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT			= (0 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT_32KHZ		= (2 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH	= (3 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_LOW		= (4 << 5),
};

#define IS_GPIO_OUTPUT(gpio) (((gpio)&kDIALOG_SYS_GPIO_DIRECTION_MASK) \
				< kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH)

enum {
	kDIALOG_WLED_CONTROL_WLED_ENABLE1	= (1 << 0),
	kDIALOG_WLED_CONTROL_WLED_ENABLE2	= (1 << 1),
	kDIALOG_WLED_CONTROL_WLED_ENABLE3	= (1 << 2),
	kDIALOG_WLED_CONTROL_WLED_ENABLE4	= (1 << 3),
	kDIALOG_WLED_CONTROL_WLED_ENABLE5	= (1 << 4),
	kDIALOG_WLED_CONTROL_WLED_ENABLE6	= (1 << 5),
};

enum {
	kDIALOG_WLED_CONTROL2_WLED_RAMP_EN	= (1 << 2),
	kDIALOG_WLED_CONTROL2_WLED_DWI_EN	= (1 << 3),
	kDIALOG_WLED_CONTROL2_WLED_DITH_EN	= (1 << 4),
	kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN	= (1 << 5),

	kDIALOG_WLED_CONTROL_WLED_DWI_EN	= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,

	kDIALOG_WLED_OPTIONS_DEFAULT		= kDIALOG_WLED_CONTROL2_WLED_DITH_EN,
	kDIALOG_WLED_OPTIONS_xWI_EN		= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,
	kDIALOG_WLED_OPTIONS_MASK		= (kDIALOG_WLED_CONTROL2_WLED_RAMP_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN),
};

#define WLED_ISET_BITS	(11)

#define NUM_LDOS 23
static const struct ldo_params ldo_1946[NUM_LDOS] = {
{ 2500, 50, 0x0a, 0x1f, 0x1, kD1946_LDO1,            kD1946_ACTIVE1, 0x20 },	// LDO1
{ 1650, 5,  0x0a, 0x1f, 0x0, kD1946_LDO2,            kD1946_ACTIVE1, 0x40 },	// LDO2
{ 2500, 50, 0x0a, 0x1f, 0x0, kD1946_LDO3,            kD1946_ACTIVE1, 0x80 },	// LDO3
{ 1800, 50, 0x18, 0x1f, 0x0, kD1946_LDO4,            kD1946_ACTIVE2, 0x01 },	// LDO4
{ 2500, 50, 0x0a, 0x1f, 0x0, kD1946_LDO5,            kD1946_ACTIVE2, 0x02 },	// LDO5
{ 2500, 50, 0x10, 0x1f, 0x2, kD1946_LDO6,            kD1946_ACTIVE2, 0x04 },	// LDO6
{ 1500, 100,0x0a, 0x1f, 0x0, kD1946_LDO7,            kD1946_ACTIVE2, 0x08 },	// LDO7
{ 2000, 50, 0x16, 0x1f, 0x0, kD1946_LDO8,            kD1946_ACTIVE2, 0x10 },	// LDO8
{ 1200, 100,0x00, 0x1f, 0x0, kD1946_LDO9,            kD1946_ACTIVE2, 0x20 },	// LDO9
{ 2500, 50, 0x0a, 0x1f, 0x4, kD1946_LDO10,           kD1946_ACTIVE2, 0x40 },	// LDO10
{ 1700, 50, 0x17, 0x1f, 0x0, kD1946_LDO11,           kD1946_ACTIVE2, 0x80 },	// LDO11
{ 600,  25, 0x14, 0x1f, 0x0, kD1946_LDO12,           kD1946_ACTIVE3, 0x01 },	// LDO12
{ 5000, 50, 0x0c, 0x1f, 0x0, kD1946_LCM_CONTROL1,    kD1946_ACTIVE3, 0x04 },	// LCM1_LDO
{ 5000, 50, 0x05, 0x1f, 0x0, kD1946_LCM_CONTROL2,    kD1946_ACTIVE3, 0x08 },	// LCM2_LDO
{ 5000, 50, 0x00, 0x1f, 0x0, kD1946_LCM_CONTROL3,    kD1946_ACTIVE3, 0x10 },	// LCM3_LDO
{ 5000, 50, 0x1f, 0x1f, 0x0, kD1946_LCM_BST_CONTROL, kD1946_ACTIVE3, 0x02 },	// LCM_BOOST
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_ACTIVE3, 0x20 },	// 17 - WLED_BST_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_ACTIVE4, 0x10 },	// 18 - DSP_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_ACTIVE4, 0x20 },	// 19 - CPU1V2_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_ACTIVE4, 0x40 },	// 20 - WDIG_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_ACTIVE4, 0x80 },	// 21 - CPU1V8_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_HIBERNATE1, 0x20 },	// 22 - set LDO1_EN in HIB
{ 0,    0,  0,    0,    0x0, 0,			     kD1946_HIBERNATE2, 0x04 },	// 23 - set LDO6_EN in HIB
};
#define LDOP ldo_1946

enum {
	kDIALOG_SYS_CONFIG_WDOG_EN		= (1 << 0),

	kDIALOG_SYS_CONFIG_WDOG_MODE_100MS	= (0 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_250MS	= (1 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_500MS	= (2 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_1000MS	= (3 << 1),

	kDIALOG_SYS_CONFIG_RESET_TIMER_MASK	= (3 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_4S	= (0 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_6S	= (1 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_8S	= (2 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_10S	= (3 << 3),
	
	kDIALOG_SYS_CONFIG_WDOG_ACTIVE		= (1 << 5),
};

enum {
	kDIALOG_BUTTON_DBL_CLICK_RATE_MASK	= (7 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_50MS	= (0 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_100MS	= (1 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_150MS	= (2 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_200MS	= (3 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_250MS	= (4 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_300MS	= (5 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_350MS	= (6 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_400MS	= (7 << 0),
	kD1946_BUTTON_DBL_BTN1_DBL_EN		= (1 << 3),
	kD1946_BUTTON_DBL_BTN2_DBL_EN		= (1 << 4),
	kD1946_BUTTON_DBL_BTN3_DBL_EN		= (1 << 5),
	kDIALOG_BUTTON_DBL_HOLD_DBL_EN		= kD1946_BUTTON_DBL_BTN2_DBL_EN,
	kDIALOG_BUTTON_DBL_MENU_DBL_EN		= kD1946_BUTTON_DBL_BTN1_DBL_EN,
	kDIALOG_BUTTON_DBL_RINGER_DBL_EN	= kD1946_BUTTON_DBL_BTN3_DBL_EN,
};
